﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="MyForum - Home" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <h3><strong>Home</strong></h3>
			    
    <div class="contentarea">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Repeater ID="SectionRepeater" runat="server" DataSourceID="SectionObjectDataSource">
                    <ItemTemplate>
                        <asp:HiddenField ID="SectionIdHiddenField" runat="server" Value='<%# Eval("Id") %>' Visible="false" />
                        <div style="margin-bottom: 15px;">
                            <div style="margin-bottom: 5px;">
                                <h4><asp:Label ID="SectionTitleLabel" runat="server" Text='<%# Eval("Title") %>'></asp:Label></h4>
                            </div>
                            
                            <div style="margin-bottom: 5px;"> 
                                <asp:GridView ID="ForumGridView" runat="server" DataSourceID="ForumObjectDataSource" AutoGenerateColumns="false" AllowSorting="true" CssClass="ForumGridView" CssSelectorClass="ForumGridView" CellSpacing="5" CellPadding="5">
                                    <Columns>
                                        <asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="~/Forum.aspx?id={0}" DataTextField="Name" HeaderText="Name" SortExpression="Name" ItemStyle-CssClass="NameColumn" />
                                        <asp:BoundField DataField="NumberOfTopic" HeaderText="Topics" SortExpression="NumberOfTopic" ItemStyle-CssClass="TopicsColumn" />
                                        <asp:BoundField DataField="NumberOfMessage" HeaderText="Messages" SortExpression="NumberOfMessage" ItemStyle-CssClass="MessagesColumn" />
                                        <asp:TemplateField HeaderText="Last Message" ItemStyle-Width="10%" SortExpression="LastMessageDate" ItemStyle-CssClass="LastMessageColumn">
                                            <ItemTemplate>
                                                <asp:Label ID="LastMessageDateLabel" runat="server" Text='<%# Eval("LastMessageDate", "{0:dd/MM/yyyy}") %>'></asp:Label>
                                                <asp:Label ID="LastMessageTitleLabel" runat="server" Text='<%# Eval("LastMessageTitle") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                                
                                <asp:ObjectDataSource ID="ForumObjectDataSource" runat="server" 
                                    OldValuesParameterFormatString="original_{0}" SelectMethod="GetAvailableForumFromSection" 
                                    TypeName="MyForum.Business.Controllers.ForumController" 
                                    SortParameterName="sortExpression">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="SectionIdHiddenField" Name="sectionId" Type="Int32" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                            </div>
                        </div>
                    </ItemTemplate>
                </asp:Repeater>
            </ContentTemplate>
        </asp:UpdatePanel>
        
        <asp:ObjectDataSource ID="SectionObjectDataSource" runat="server" 
            SelectMethod="GetAvailableSection" 
            TypeName="MyForum.Business.Controllers.SectionController" 
            SortParameterName="sortExpression" EnablePaging="false" 
            SelectCountMethod="GetAvailableSectionCount">
        </asp:ObjectDataSource>
    </div>
</asp:Content>
